<hz-page-header header="{$ 'Images' | translate $}"></hz-page-header>

<table ng-controller="imagesTableController as table"
       hz-table ng-cloak
       st-table="table.images"
       st-safe-src="table.imagesSrc"
       default-sort="name"
       default-sort-reverse="false"
       class="table-striped table-rsp table-detail modern">

  <thead>
    <tr>
      <!--
        Table-batch-actions:
        This is where batch actions like searching, creating, and deleting.
      -->
      <th colspan="100" class="search-header">
        <hz-search-bar group-classes="input-group-sm" icon-classes="fa-search">
        </hz-search-bar>
      </th>
    </tr>

    <tr>
      <!--
        Table-column-headers:
        This is where we declaratively define the table column headers.
        Include select-col if you want to select all.
        Include expander if you want to inline details.
        Include action-col if you want to perform actions.
      -->
      <th class="select-col">
        <input type="checkbox" hz-select-all="table.images">
      </th>

      <th class="expander"></th>

      <th class="rsp-p1" st-sort="name" st-sort-default="name" translate>Image Name</th>
      <th class="rsp-p1" st-sort="type" translate>Type</th>
      <th class="rsp-p1" st-sort="status" translate>Status</th>
      <th class="rsp-p2" st-sort="is_public" translate>Public</th>
      <th class="rsp-p2" st-sort="protected" translate>Protected</th>
      <th class="rsp-p2" st-sort="disk_format" translate>Format</th>
      <th class="rsp-p2" st-sort="size" translate>Size</th>
    </tr>
  </thead>

  <tbody>
    <!--
      Table-rows:
      This is where we declaratively define the table columns.
      Include select-col if you want to select all.
      Include expander if you want to inline details.
      Include action-col if you want to perform actions.
      rsp-p1 rsp-p2 are responsive priority as user resizes window.
    -->
    <tr ng-repeat-start="image in table.images track by image.id"
        ng-class="{'st-selected': checked[image.id]}">

      <td class="select-col">
        <input type="checkbox"
               ng-model="selected[image.id].checked"
               hz-select="image">
      </td>
      <td class="expander">
        <i class="fa fa-chevron-right"
           hz-expand-detail
           duration="200">
        </i>
      </td>
      <td class="rsp-p1">{$ image.name $}</td>
      <td class="rsp-p1">{$ image | imageType $}</td>
      <td class="rsp-p1">{$ image.status | imageStatus $}</td>
      <td class="rsp-p2">{$ image.is_public | yesno $}</td>
      <td class="rsp-p2">{$ image.protected | yesno $}</td>
      <td class="rsp-p2">{$ image.disk_format | noValue | uppercase $}</td>
      <td class="rsp-p2">{$ image.size | bytes $}</td>
    </tr>

    <tr ng-repeat-end class="detail-row">
      <!--
        Detail-row:
        Contains detailed information on this item.
        Can be toggled using the chevron button.
        Ensure colspan is greater or equal to number of column-headers.
      -->
      <td class="detail" colspan="100">
        <!--
          The responsive columns that disappear typically should reappear here
          with the same responsive priority that they disappear.
          E.g. table header with rsp-p2 should be here with rsp-alt-p2
        -->
        <div class="row">
          <span class="rsp-alt-p2">
            <dl class="col-sm-2">
              <dt translate>Public</dt>
              <dd>{$ image.is_public | yesno $}</dd>
            </dl>
            <dl class="col-sm-2">
              <dt translate>Protected</dt>
              <dd>{$ image.protected | yesno $}</dd>
            </dl>
            <dl class="col-sm-2">
              <dt translate>Format</dt>
              <dd>{$ image.disk_format | noValue $}</dd>
            </dl>
            <dl class="col-sm-2">
              <dt translate>Size</dt>
              <dd>{$ image.size | bytes $}</dd>
            </dl>
          </span>
        </div>

        <div class="row">
          <dl class="col-sm-2">
            <dt translate>Min Disk (GB)</dt>
            <dd>{$ image.min_disk | noValue $}</dd>
          </dl>
          <dl class="col-sm-2">
            <dt translate>Min RAM (MB)</dt>
            <dd>{$ image.min_ram | noValue $}</dd>
          </dl>
        </div>

        <!-- TODO Add in metadata defs from launch instance image details -->
      </td>
    </tr>

  </tbody>
  <!--
    Table-footer:
    This is where we display number of items and pagination controls.
  -->
  <tfoot hz-table-footer items="table.images"></tfoot>

</table>
